function write_serial(str)
% write_serial  Write to port initialized by tcs2.init
%   write_serial(str)

global TCS2_SERIAL

if isempty(TCS2_SERIAL)
    error('Serial connection not initialized. Please run tcs2.init_serial first.')
end

if tcs2.verbose >= 2
    disp(['sending: "' str '"'])
end

if ~strcmp(TCS2_SERIAL.Port,'DUMMY')
    for i=1:length(str)
        fwrite(TCS2_SERIAL,str(i),'uchar') ; 
        pause(0.001) ;
    end
end
